﻿<UserControl x:Class="Fluffy.FileMenuCommands.RecentDocumentsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:fileMenuCommands="clr-namespace:Fluffy.FileMenuCommands"
             mc:Ignorable="d" d:DataContext="{d:DesignInstance fileMenuCommands:OpenCommandViewModel}"
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <ListView ItemsSource="{Binding RecentDocuments}" Background="Transparent" BorderThickness="0" ScrollViewer.VerticalScrollBarVisibility="Disabled" FocusVisualStyle="{x:Null}"
                  Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=fileMenuCommands:RecentDocumentsView}, Path=Foreground}">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalAlignment" Value="Stretch"/>
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListViewItem}">
                                <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                    <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="#22000000"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.ItemTemplate>
                <DataTemplate DataType="fileMenuCommands:FilePathViewModel">
                    <Button Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=fileMenuCommands:RecentDocumentsView}, Path=DataContext.OpenSpecifiedDocumentCommand}" 
                            CommandParameter="{Binding FilePath}" HorizontalAlignment="Stretch" 
                            Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Path=Foreground}">
                        <Button.Template>
                            <ControlTemplate TargetType="Button">
                                <DockPanel Background="Transparent" ToolTip="{Binding FilePath}">
                                    <Image DockPanel.Dock="Left" Margin="0,0,3,0" Source="{Binding Icon}"/>
                                    <TextBlock DockPanel.Dock="Top" Text="{Binding FileName}" MaxWidth="300" TextTrimming="CharacterEllipsis" Foreground="{TemplateBinding Foreground}"/>
                                    <TextBlock Text="{Binding FileDir}" MaxWidth="300" TextTrimming="CharacterEllipsis" Foreground="{TemplateBinding Foreground}"/>
                                </DockPanel>
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</UserControl>
